#include <gui/sportpage_screen/SportPageView.hpp>
#include "BitmapDatabase.hpp"

SportPageView::SportPageView() :
		SportScrollListItemSelectedCallback(this, &SportPageView::SportScrollListItemSelectedHandler)
{

}

void SportPageView::setupScreen()
{
    // The item selected callbacks are registerd with scroll wheel and list
    SportScrollList.setItemSelectedCallback(SportScrollListItemSelectedCallback);

    // The scroll wheel and list is updated to show the selected icons and numbers.
    for (int i = 0; i < SportScrollListListItems.getNumberOfDrawables(); i++)
    {
        SportScrollList.itemChanged(i);
    }
}
//
void SportPageView::tearDownScreen()
{
    SportPageViewBase::tearDownScreen();
}
//退出运动模式界面
void SportPageView::SportPageExit(uint8_t newFiveKeyFunc)
{
		handleKeyEvent(newFiveKeyFunc);
}
// The scrollListUpdateItem is called by the base view each time an element in the scroll list is updated.
// By having a reference to the instance, which the switch updates the image based on the index the item has.
void SportPageView::SportScrollListUpdateItem(SportElement& item, int16_t itemIndex)
{
    switch (itemIndex)
    {
    case 0:
        item.updateImage(Bitmap(BITMAP_SPORT_CYCLING_ID));
        break;
    case 1:
        item.updateImage(Bitmap(BITMAP_SPORT_INDOOR_RUNNING_ID));
        break;
    case 2:
        item.updateImage(Bitmap(BITMAP_SPORT_OUTDOORS_RUNNING_ID));
        break;
    case 3:
        item.updateImage(Bitmap(BITMAP_SPORT_SELF_TRAINING_ID));
        break;
    case 4:
        item.updateImage(Bitmap(BITMAP_SPORT_SWIMMING_ID));
        break;
    case 5:
        item.updateImage(Bitmap(BITMAP_SPORT_WALK_ID));
        break;
    }
}
// The callback updates the selectedIcon bast on the itemSelected parameter
void SportPageView::SportScrollListItemSelectedHandler(int16_t itemSelected)
{
    switch (itemSelected)
    {
    case 0:	//CYCLING
        //添加<户外骑行>页面跳转代码
        break;
    case 1:	//INDOOR_RUNNING
        //添加<室内跑步>页面跳转代码
        break;
    case 2:	//OUTDOORS_RUNNING
        //添加<户外跑步>页面跳转代码
        break;
    case 3:	//SELF_TRAINING
        //添加<自由训练>页面跳转代码
        break;
    case 4:	//SWIMMING
        //添加<室内游泳>页面跳转代码
        break;
    case 5:	//WALK
        application().gotoHikingPageScreenCoverTransitionEast();
        break;

    }
}